package com.javajun.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;

/**
 * @className: SysUser
 * @description: 所有用户的父类
 * @author: JavaJun
 * @date: 2018年10月29日
 */
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class SysUser {

    private Integer id;
    // 真实姓名，长度20
    private String name;
    // 用户，长度50
    private String username;
    // 密码
    private String password;
    // 创建日期
    private Date creatDate;
    // 创建人
    private String creatUser;
    // 是否删除
    private Integer deleted;
    protected List<UserRole> roles = new ArrayList<>();
    
    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    
    @Column(length=20)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    
    @Column(length=50, unique=true)
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    
    
    public String getCreatUser() {
        return creatUser;
    }
    public void setCreatUser(String creatUser) {
        this.creatUser = creatUser;
    }
    
    @Column(name="is_deleted")
    public Integer getDeleted() {
        return deleted;
    }
    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }
    
    public Date getCreatDate() {
        return creatDate;
    }
    public void setCreatDate(Date creatDate) {
        this.creatDate = creatDate;
    }
    
    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    public List<UserRole> getRoles() {
        return roles;
    }
    public void setRoles(List<UserRole> roles) {
        this.roles = roles;
    }
    
}
